
/*
 * Copyright (C) 2008-2009 Archie L. Cobbs. All rights reserved.
 *
 * $Id$
 */

package org.dellroad.sidekar.schema.change;

/**
 * Adapter class for the {@link SchemaChangeSwitch} interface.
 */
public class SchemaChangeAdapter implements SchemaChangeSwitch {

    /**
     * Handle a {@link AddEntityChange}.
     *
     * <p>
     * The implementation in {@link SchemaChangeAdapter} delegates to {@link #caseEntityChange}.
     */
    @Override
    public void caseAddEntityChange(AddEntityChange change) {
        this.caseEntityChange(change);
    }

    /**
     * Handle a {@link RemoveEntityChange}.
     *
     * <p>
     * The implementation in {@link SchemaChangeAdapter} delegates to {@link #caseEntityChange}.
     */
    @Override
    public void caseRemoveEntityChange(RemoveEntityChange change) {
        this.caseEntityChange(change);
    }

    /**
     * Handle a {@link RenameEntityChange}.
     *
     * <p>
     * The implementation in {@link SchemaChangeAdapter} delegates to {@link #caseEntityChange}.
     */
    @Override
    public void caseRenameEntityChange(RenameEntityChange change) {
        this.caseEntityChange(change);
    }

    /**
     * Handle a {@link EntityAbstractnessChange}.
     *
     * <p>
     * The implementation in {@link SchemaChangeAdapter} delegates to {@link #caseEntityChange}.
     */
    @Override
    public void caseEntityAbstractnessChange(EntityAbstractnessChange change) {
        this.caseEntityChange(change);
    }

    /**
     * Handle a {@link AddFieldChange}.
     *
     * <p>
     * The implementation in {@link SchemaChangeAdapter} delegates to {@link #caseFieldChange}.
     */
    @Override
    public void caseAddFieldChange(AddFieldChange change) {
        this.caseFieldChange(change);
    }

    /**
     * Handle a {@link RemoveFieldChange}.
     *
     * <p>
     * The implementation in {@link SchemaChangeAdapter} delegates to {@link #caseFieldChange}.
     */
    @Override
    public void caseRemoveFieldChange(RemoveFieldChange change) {
        this.caseFieldChange(change);
    }

    /**
     * Handle a {@link AddIndexChange}.
     *
     * <p>
     * The implementation in {@link SchemaChangeAdapter} delegates to {@link #caseEntityChange}.
     */
    @Override
    public void caseAddIndexChange(AddIndexChange change) {
        this.caseEntityChange(change);
    }

    /**
     * Handle a {@link RenameEntityChange}.
     *
     * <p>
     * The implementation in {@link SchemaChangeAdapter} delegates to {@link #caseEntityChange}.
     */
    @Override
    public void caseRemoveIndexChange(RemoveIndexChange change) {
        this.caseEntityChange(change);
    }

    /**
     * Internal roll-up method.
     *
     * <p>
     * The implementation in {@link SchemaChangeAdapter} delegates to {@link #caseEntityChange}.
     */
    protected void caseFieldChange(FieldChange change) {
        this.caseEntityChange(change);
    }

    /**
     * Internal roll-up method.
     *
     * <p>
     * The implementation in {@link SchemaChangeAdapter} delegates to {@link #caseDefault}.
     */
    protected void caseEntityChange(EntityChange change) {
        this.caseDefault(change);
    }

    /**
     * Internal roll-up method.
     *
     * <p>
     * The implementation in {@link SchemaChangeAdapter} does nothing.
     */
    protected void caseDefault(SchemaChange change) {
    }
}
